package com.cloudeye.business.base.rabbitmq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by lafangyuan on 2021/6/29.
 */
@Service
public class DbService {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public Map getFlightD(){
        String sql = "SELECT * from dynamic_flight where in_out_flag='D' and exec_date=current_date";
        return jdbcTemplate.queryForMap(sql);
    }
    public List<Map<String,Object>> getPsgCurrent(){
        String sql = "SELECT * from passenger where  psg_fltdt=current_date";
        return jdbcTemplate.queryForList(sql);
    }

    public Integer getNextLugId(){
        String sql = "SELECT max(t.lug_id) from luggage t";
        Integer integer = jdbcTemplate.queryForObject(sql, Integer.class);
        if(integer==null){
            return 1000;
        }
        return integer+1;
    }
}
